package com.dhcc.bpm.modules.log.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dhcc.bpm.common.utils.DateUtils;
import com.dhcc.bpm.modules.api.vo.ApiVO;
import com.dhcc.bpm.modules.log.entity.GatewayLog;
import com.dhcc.bpm.modules.log.entity.GatewayLogDay;
import com.dhcc.bpm.modules.log.entity.GatewayLogMinute;
import com.dhcc.bpm.modules.log.mapper.GatewayLogMapper;
import com.dhcc.bpm.modules.log.service.IGatewayLogService;
import com.dhcc.bpm.modules.log.vo.GatewayLogVO;
import com.dhcc.bpm.modules.log.vo.TodayRequestNum;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @ClassName GatewayLogServiceImpl.class
 * @Description 网关访问记录表 服务实现类
 * @Author xiaFaYu
 * @Date 2019-12-16 14:16
 * @Version V1.0
 * @Copyright: 2020 东华软件 . All rights reserved.
 */
@Service
public class GatewayLogServiceImpl extends BaseServiceImpl<GatewayLogMapper, GatewayLog> implements IGatewayLogService {
    @Autowired
    private GatewayLogMapper gatewayLogMapper;

    /**
     * @param page
     * @param gatewayLog
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.log.vo.GatewayLogVO>
     * @Description 自定义分页
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public IPage<GatewayLogVO> selectGatewayLogPage(IPage<GatewayLogVO> page, GatewayLogVO gatewayLog) {
        return page.setRecords(baseMapper.selectGatewayLogPage(page, gatewayLog));
    }

    @Override
    public IPage<GatewayLogVO> selectGatewayLogByApi(IPage<GatewayLogVO> page, GatewayLogVO gatewayLog) {
        return page.setRecords(baseMapper.selectGatewayLogVOByApi(page, gatewayLog));
    }

    @Override
    public IPage<GatewayLogVO> selectGatewayLogVOPage(IPage<GatewayLogVO> page, GatewayLogVO gatewayLog) {
        return page.setRecords(baseMapper.selectGatewayLogVOPage(page, gatewayLog));
    }


    @Override
    public List<GatewayLogVO> selectApiByBaseProductId(GatewayLogVO gatewayLog) {
        return baseMapper.selectApiByBaseProductId(gatewayLog);
    }

    @Override
    public List<GatewayLogVO> selectApiCodeBySysId(GatewayLogVO gatewayLog) {
        return baseMapper.selectApiCodeBySysId(gatewayLog);
    }

    @Override
    public List<GatewayLogVO> selectApiByProductId(GatewayLogVO gatewayLog) {
        return baseMapper.selectApiByProductId(gatewayLog);
    }

    @Override
    public List<GatewayLogVO> selectApiByApiId(GatewayLogVO gatewayLog) {
        return baseMapper.selectApiByApiId(gatewayLog);
    }

    /**
     * @param page
     * @param gatewayLog
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.log.vo.GatewayLogVO>
     * @Description 查询接口访问记录
     * @Author daina
     * @Date 15:41 2020/3/23
     **/
    @Override
    public IPage<GatewayLogVO> listGatewayLogPage(IPage<GatewayLogVO> page, GatewayLogVO gatewayLog) {
        return page.setRecords(baseMapper.listGatewayLogPage(page, gatewayLog));
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectApiSuccessCount(GatewayLog gatewayLog) {
        return baseMapper.selectApiSuccessCount(gatewayLog);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectApiFailCount(GatewayLog gatewayLog) {
        return baseMapper.selectApiFailCount(gatewayLog);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectFailCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.selectFailCount(gatewayLog);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectGateCount(GatewayLog gatewayLog) {
        return baseMapper.selectGateCount(gatewayLog);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int gateCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.gateCount(gatewayLog);
    }

    /**
     * @param appCode
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectBusCount(GatewayLog appCode) {
        return baseMapper.selectBusCount(appCode);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int busCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.busCount(gatewayLog);
    }

    /**
     * @param appCode
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectInfoCount(GatewayLog appCode) {
        return baseMapper.selectInfoCount(appCode);
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int infoCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.infoCount(gatewayLog);
    }

    /**
     * @param page
     * @param api
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.api.vo.ApiVO>
     * @Description 某一机构下API列表以及统计信息
     * @Author Mdd
     * @Date 2020/3/7 17:20
     **/
    @Override
    public IPage<ApiVO> selectOrgaApiCount(IPage<ApiVO> page, ApiVO api) {
        return page.setRecords(gatewayLogMapper.selectOrgaApiCount(page, api));
    }

    /**
     * @param page
     * @param api
     * @return com.baomidou.mybatisplus.core.metadata.IPage<com.dhcc.bpm.modules.api.vo.ApiVO>
     * @Description 某一机构下API列表以及统计信息
     * @Author Mdd
     * @Date 2020/3/7 17:20
     **/
    @Override
    public IPage<ApiVO> selectProApiCount(IPage<ApiVO> page, ApiVO api) {
        return page.setRecords(gatewayLogMapper.selectProApiCount(page, api));
    }

    /**
     * @param gatewayLog
     * @return int
     * @Description 查询
     * @Author xiafayu
     * @Date 2020/2/24 15:37
     **/
    @Override
    public int selectSuccessCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.selectSuccessCount(gatewayLog);
    }

    @Override
    public int queryCount(GatewayLog gatewayLog) {
        return gatewayLogMapper.queryCount(gatewayLog) == null ? 0 : gatewayLogMapper.queryCount(gatewayLog);
    }

    @Override
    public TodayRequestNum queryToDayCount(GatewayLog gatewayLog) {
        gatewayLog.setRequestDate(DateUtils.date());
        return gatewayLogMapper.queryToDayCount(gatewayLog);
    }

    @Override
    public String getDSNowDate() {
        return gatewayLogMapper.getDSNowDate();
    }

    @Override
    public String getDSNowTime() {
        return gatewayLogMapper.getDSNowTime();
    }

    @Override
    public String getNowTime() {
        return gatewayLogMapper.getNowTime();
    }

    @Override
    public int updateMinuteData(GatewayLogMinute opcGatewayLogMinute) {
        return gatewayLogMapper.updateMinuteData(opcGatewayLogMinute);
    }

    @Override
    public List<GatewayLog> findList(GatewayLog opcGatewayLog) {
        return gatewayLogMapper.findList(opcGatewayLog);
    }

    @Override
    public int insertDailyData(GatewayLogDay opcGatewayLogDay) {
        return gatewayLogMapper.insertDailyData(opcGatewayLogDay);
    }

    @Override
    public GatewayLogDay findDailyData(GatewayLogDay opcGatewayLogDay) {
        return gatewayLogMapper.findDailyData(opcGatewayLogDay);
    }

    @Override
    public int updateDailyData(GatewayLogDay opcGatewayLogDay) {
        return gatewayLogMapper.updateDailyData(opcGatewayLogDay);
    }

    @Override
    public GatewayLogMinute findMinuteData(GatewayLogMinute opcGatewayLogMinute) {
       return gatewayLogMapper.findMinuteData(opcGatewayLogMinute);
    }

    @Override
    public int insertMinuteData(GatewayLogMinute opcGatewayLogMinute) {
        return gatewayLogMapper.insertMinuteData(opcGatewayLogMinute);
    }

    @Override
    public int saveLog(GatewayLog opcGatewayLog) {
        return gatewayLogMapper.saveLog(opcGatewayLog);
    }

    @Override
    public List<GatewayLogMinute> findMinuteList(GatewayLogMinute opcGatewayLogMinute) {
        return gatewayLogMapper.findMinuteList(opcGatewayLogMinute);
    }

    @Override
    public List<GatewayLogDay> findListGroup(GatewayLog opcGatewayLog) {
        return gatewayLogMapper.findListGroup(opcGatewayLog);
    }

    @Override
    public List<GatewayLogDay> findMinuteListGroup(GatewayLogMinute opcGatewayLog) {
        return gatewayLogMapper.findMinuteListGroup(opcGatewayLog);
    }

    @Override
    public String findSysName(String apiCode) {
        return gatewayLogMapper.findSysName(apiCode);
    }

    @Override
    public List<GatewayLog> queryThirdMonthAgoLogList(String lastDate) {
        return gatewayLogMapper.queryThirdMonthAgoLogList(lastDate);
    }

    @Override
    public List<GatewayLogMinute> queryThirdMonthAgoLogMinuteList(String lastDate) {
        return gatewayLogMapper.queryThirdMonthAgoLogMinuteList(lastDate);
    }

    @Override
    public List<GatewayLogDay> queryThirdMonthAgoLogDayList(String lastDate) {
        return gatewayLogMapper.queryThirdMonthAgoLogDayList(lastDate);
    }

}
